#!/bin/sh

######################################
#       Slackware Build Script       #
######################################
#  AUTHOR: Lehman Black              #
# CONTACT: bzqwerty[at]gmail[dot]com #
######################################

# Modified by the SlackBuilds.org project

PROG=exo
VERSION=0.3.1.12rc2
ARCH=${ARCH:-i486}
TAG=${TAG:-_SBo}
BUILD=${BUILD:-1}

CWD=`pwd`
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PROG
OUTPUT=${OUTPUT:-/tmp}

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP || exit 1
tar xvf $CWD/$PROG-$VERSION.tar.gz || exit 1
cd $PROG-$VERSION || exit 1

if [ "$ARCH" = "i486" ]; then
	SLKCFLAGS="-O2 -march=i486 -mtune=i686"
elif [ "$ARCH" = "i586" ]; then
	SLKCFLAGS="-O2 -march=i586 -mtune=i686"
elif [ "$ARCH" = "i686" ]; then
	SLKCFLAGS="-O2 -march=i686 -mtune=i686"
fi

CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --enable-static=no \
  || exit 1

make || exit 1
make install-strip DESTDIR=$PKG || exit 1

mkdir -p $PKG/usr/doc/$PROG-$VERSION
cp -av AUTHORS COPYING ChangeLog HACKING INSTALL NEWS README THANKS TODO \
  $PKG/usr/doc/$PROG-$VERSION
cat $CWD/$PROG.SlackBuild > $PKG/usr/doc/$PROG-$VERSION/$PROG.SlackBuild

gzip -9 $PKG/usr/man/man?/*

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c y $OUTPUT/$PROG-$VERSION-$ARCH-$BUILD$TAG.tgz
